package com.yxlgateway.gateway.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxlcommon.common.pojo.OrderComment;
import com.yxlcommon.common.pojo.RespBean;
import com.yxlgateway.service.OrderCommentService;
import com.yxlcommon.common.vo.OrderCommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: yxl
 * @since: 2022-01-14
 **/
@RestController
@RequestMapping("/orderComment")
public class OrderCommentController {

    @Autowired
    private OrderCommentService orderCommentService;

    @PostMapping("/addOrderComment")
    public RespBean addOrderComment(@RequestBody OrderComment orderComment){
        return RespBean.operationSuccess("评论成功", 200, orderCommentService.addComment(orderComment));
    }

    @PostMapping("/replyComment")
    public RespBean replyComment(@RequestBody OrderComment orderComment){
        return RespBean.operationSuccess("回复成功！",200,orderCommentService.updateReplyComment(orderComment));
    }

    @PostMapping("/getAllOrderCommentsByPage")
    public RespBean<IPage<OrderComment>> getAllOrderCommentsByPage(@RequestParam(defaultValue = "1") Integer currentPage,
                                                                   @RequestParam(defaultValue = "10") Integer size,
                                                                   @RequestBody OrderComment orderComment){
        return orderCommentService.selectAllOrderCommentsByPage(currentPage,size,orderComment);
    }

    @PostMapping("/changeOrderCommentById")
    public RespBean<Integer> changeOrderCommentById(@RequestBody OrderComment orderComment){
        return orderCommentService.changeOrderCommentById(orderComment);
    }

    @PostMapping("/adminAddOrderComment")
    public RespBean<Integer> adminAddOrderComment(@RequestBody OrderComment orderComment){
        return orderCommentService.adminAddOrderComment(orderComment);
    }

    @PostMapping("/selectCommentById")
    public RespBean<OrderCommentVo> selectCommentById(@RequestBody OrderComment orderComment){
        return orderCommentService.selectCommentById(orderComment);
    }

    @PostMapping("/deleteOrderCommentById")
    public RespBean<Integer> deleteOrderCommentById(@RequestBody OrderComment orderComment){
        return orderCommentService.deleteOrderCommentById(orderComment);
    }

}
